ans = 0
def sum_4(n):
    s = 0
    while n > 0:
        s += n % 4  # 获取当前最低位的四进制数字
        n = n // 4  # 移除已处理的最低位
    return s

def sum_2(n):
    s = 0
    while n > 0:
        s += n % 2
        n = n // 2
    return s

for i in range(1, 2025):
    if sum_2(i) == sum_4(i):
        ans += 1
print(ans)